
package com.joysuch.wwyt.datadump.biz.query;

import cn.zlg.common.datadump.condition.QueryCondtionDef;
import cn.zlg.common.datadump.condition.QueryFieldCondition;
import cn.zlg.common.datadump.condition.QueryFieldConditionSet;
import cn.zlg.common.datadump.condition.SortFieldDef;
import com.joysuch.wwyt.core.entity.dsl.QBaseUser;
import com.joysuch.wwyt.datadump.biz.condition.BaseUserDumpFindSubdepartIdConditionBuilder;
import com.joysuch.wwyt.datadump.biz.condition.EduQuestionDumpCreateTimeConditionBuilder;
import com.joysuch.wwyt.edu.entity.dsl.QEduCertificate;
import com.joysuch.wwyt.edu.entity.dsl.QEduCertificateUser;
import com.joysuch.wwyt.edu.entity.dsl.QEduQuestion;
import com.joysuch.wwyt.mh.entity.dsl.QMhMajorHazard;
import com.joysuch.wwyt.util.ApplicationContextHolder;
import com.querydsl.core.types.Order;

import java.util.Arrays;
import java.util.List;

public class EduQuestionDumpQueryBean implements QueryCondtionDef {

    @Override
    public List<QueryFieldConditionSet> getConditionSet() {
        QEduQuestion q = QEduQuestion.eduQuestion;
        return Arrays.asList(
                QueryFieldConditionSet.Builder().names("nameOrCode").or(
                        new QueryFieldCondition("", q, q.name, q.id,
                                "contains"),
                        new QueryFieldCondition("", q, q.code, q.id,
                                "contains")
                ).build()
        );
    }

    @Override
    public QueryFieldCondition[] getAllConditionDef() {
        QEduQuestion q = QEduQuestion.eduQuestion;
        return new QueryFieldCondition[] {
                new QueryFieldCondition("ids", q,
                        q.id, q.id, "in"),
                // new QueryFieldCondition("nameOrCode", q,
                // q.name, q.id,
                // "contains"),
                new QueryFieldCondition("questionTypeId", q,
                        q.questionTypeId, q.id, "eq"),
                new QueryFieldCondition("type", q,
                        q.type, q.id, "eq"),
                new QueryFieldCondition("createTime", q,
                        q.createTime, ApplicationContextHolder.getBean(EduQuestionDumpCreateTimeConditionBuilder.class), "eq"),
                // 人员类型
        };
    }

    @Override
    public SortFieldDef[] getAllSortFieldDef() {
        return new SortFieldDef[] {
                new SortFieldDef(QEduQuestion.eduQuestion.id, "id", Order.DESC, true),
        };
    }
}
